<?php 

/**
 * FreeY_Paginator_Helper
 *
 * @auther		FreeYadmin <FreeYadmin@gmail.com>
 * @update		none
 * @package		FreeY
 */	
class FreeY_Paginator_Helper_Db extends FreeY_Paginator_Helper_Abstract
{
	/**
	* public_note
	* 
	* @param	$var		array		note
	* @return	$ret		array		note
	*/
	public function db($db)
	{		
		$this->db = $db;
	}

	/**
	* public_note
	* 
	* @param	$var		array		note
	* @return	$ret		array		note
	*/
	public function sql($sql)
	{		
		$this->sql = $sql;
	}

	/**
	* method_note
	*	
	* @param	$var		type		note
	* @return	$ret		type		note
	*/
	public function create()
	{
		$count = $this->db->count($this->sql->toString());
		$this->paginator = new FreeY_Paginator($count, $this->page, $this->size);
	}

	/**
	* public_note
	* 
	* @param	$var		array		note
	* @return	$ret		array		note
	*/
	public function data()
	{		
		$this->sql->limit($this->paginator->getSize(), $this->paginator->getLimitStart());
		return $this->db->result($this->sql->toString());
	}

}//FreeY end**********
//file end--------------------------------------------------------->